package com.bwie.product.controller;

import com.bwie.common.core.domain.Result;
import com.bwie.common.redis.service.RedisService;
import com.bwie.product.interceptor.CheckIdempotent;
import com.bwie.product.service.OrderService;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.UUID;
import java.util.concurrent.TimeUnit;

@RequestMapping
@RestController
@CrossOrigin
@Log4j2
public class OrderController {
    @Autowired
    private OrderService orderService;

    @Autowired
    private RedisService redisService;
    @GetMapping("/OrderList/{skuId}")
    public Result OrderList(@PathVariable Integer skuId){
        orderService.OrderList(skuId);
        Result success = Result.success();
        return success;
    }
    @GetMapping("getToken")
    public Result getToken(){
        String token = UUID.randomUUID().toString().replaceAll("-", "");
        redisService.setCacheObject(token,token,5L, TimeUnit.MINUTES);
        return Result.success(token);
    }


}
